package com_djm_2025_05_15;

/**
 * @author dengjiangming
 * @version 1.0.0
 * @date 2025-05-15
 */

//递归求和
public class Demo3 {

    //递归求 1 + 2 + 3 + ... + 10
    public static int func(int n) {
        if (n == 1) {
            return 1;
        }

        return n + func(n - 1);
    }


    public static void main(String[] args) {
        int sum = func(10);
        System.out.println(sum);
    }
}
